<?php
include 'conn.php';

$yonghuming = $_POST['yonghuming'];
$mima = $_POST['mima'];
$xingming = $_POST['xingming'];
$banji = $_POST['banji'];
$xuehao = $_POST['xuehao'];
$xingbie = $_POST['xingbie'];
$xingquaihao = "";
$gerenjianjie =$_POST['gerenjianjie'];
foreach($_POST['xingquaihao'] as $item){
	 if($item == 1){
		 $xingquaihao = $xingquaihao . "读书 ";
	 }elseif($item == 2){
		 $xingquaihao = $xingquaihao . "跑步 ";
	 }elseif($item == 3){
		 $xingquaihao = $xingquaihao . "羽毛球 ";
	 }elseif($item == 4){
		 $xingquaihao = $xingquaihao . "排球 ";
	 }
 }

$sql = "INSERT INTO students (uname, upwd, realname,unumber,gender,class,xingqu,mark,regtime) VALUES ('".$yonghuming."', '".$mima."', '".$xingming."',".$xuehao.",".$xingbie.",".$banji.",'".$xingquaihao."','".$gerenjianjie."',".time().")";
if ($conn->query($sql) === TRUE) {
    echo "插入成功";
} else {
    echo "插入失败: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
